#
# MAINTAINER        Carson,C.J.Zeong <zcy@nicescale.com>
# DOCKER-VERSION    1.6.2
#
# Dockerizing CentOS7: Dockerfile for building CentOS images
#
FROM       centos:centos7.1.1503
MAINTAINER Carson,C.J.Zeong <zcy@nicescale.com>

ENV TZ "Asia/Shanghai"
ENV TERM xterm

ADD aliyun-mirror.repo /etc/yum.repos.d/CentOS-Base.repo
ADD aliyun-epel.repo /etc/yum.repos.d/epel.repo

RUN yum install -y curl wget tar bzip2 unzip vim-enhanced passwd sudo yum-utils hostname net-tools rsync man && \
    yum install -y gcc gcc-c++ git make automake cmake patch logrotate python-devel libpng-devel libjpeg-devel && \
    yum install -y --enablerepo=epel pwgen python-pip && \
    yum clean all

RUN pip install supervisor
ADD supervisord.conf /etc/supervisord.conf

RUN mkdir -p /etc/supervisor.conf.d && \
    mkdir -p /var/log/supervisor

RUN mkdir -p /data/opt
RUN mkdir -p /data/other

# Install yum packages required for build node
COPY yum-packages.list /data/opt/yum.packages.list
RUN chmod +r /data/opt/yum.packages.list
#RUN npm install -g npm
RUN yum install -y -q `cat /data/opt/yum.packages.list`

# sysctl init
COPY sysctl.txt /data/opt/
RUN cat >> /etc/sysctl.conf < /data/opt/sysctl.txt
RUN /sbin/sysctl -p
RUN sed -i '/ulimit/d' /etc/rc.d/rc.local
RUN echo "ulimit -SHn 65535" >> /etc/rc.d/rc.local
RUN cat >> /etc/security/limits.conf << EOF && \
*	soft	nofile	65535 && \
*	hard	nofile	65535 && \
EOF

RUN yum -y install ntp
RUN /usr/sbin/ntpdate

#close selinux
RUN sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
RUN /usr/sbin/setenforce 0

EXPOSE 22

ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]
